package com.slipper.system.codeless.controller;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.system.codeless.bo.ScriptExecuteBO;
import com.slipper.system.codeless.service.ScriptExecuteService;
import com.slipper.util.ResultUtil;
import com.slipper.util.Tool;

@RestController
@RequestMapping("/system/scriptExecute")
public class ScriptExecuteController {
    @Resource
    private ScriptExecuteService scriptExecuteService;
    
    @PostMapping(value = "/queryBy")
    public String queryBy(@RequestBody ScriptExecuteBO bo) {
        if(Tool.isBlank(bo.getId())) {
            return ResultUtil.failureResult("数据获取失败！");
        }
        return ResultUtil.successResult(scriptExecuteService.queryBy(bo.getId()));
    }

    @PostMapping(value = "/queryList")
    public String queryList(@RequestBody ScriptExecuteBO bo) {
        return ResultUtil.successResult(scriptExecuteService.queryList(bo));
    }

    @PostMapping(value = "/queryExecuteCount")
    public String queryExecuteCount(@RequestBody ScriptExecuteBO bo) {
        return ResultUtil.successResult(scriptExecuteService.queryExecuteCount(bo));
    }
    
    @PostMapping(value = "/queryPage")
    public String queryPage(@RequestBody ScriptExecuteBO bo) {
        return ResultUtil.successResult(scriptExecuteService.queryPage(bo));
    }

    @PostMapping(value = "/save")
    public String save(@RequestBody ScriptExecuteBO bo) {
        return ResultUtil.saveResult(scriptExecuteService.save(bo), bo);
    }

    @PostMapping(value = "/delete")
    public String delete(@RequestBody ScriptExecuteBO bo) {
        return ResultUtil.deleteResult(scriptExecuteService.delete(bo));
    }
}
